package com.yhb.demo.dao;

import com.yhb.demo.beans.UserInfo;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface UserDao {

    //通过id查询人的信息
    @Select("select * from person where id=#{id}")
    public UserInfo getUserById(@Param("id") int id);

    //根据卡号查询
    @Select("select * from person where cardno=#{cardno}")
    public UserInfo getUserByCardno(@Param("cardno")String cardno);

    //新增人员
    @Insert("insert into person(cardno,psname) values(#{cardno},#{psname})")
    public int insertUser(@Param("cardno")String cardno,@Param("psname")String psname);

    //查询全部人员信息
    @Select("select * from person")
    public List<UserInfo> getAllUser();

    //删除人员信息
    @Delete("delete from person where id=#{id}")
    public int deleteById(@Param("id")int id);

    //更新人员信息
    @Update("update person set cardno=#{cardno},psname=#{psname} where id=#{id}")
    public int updateById(@Param("id")int id,@Param("cardno")String cardno,@Param("psname")String psname);

}
